import java.util.Random;

class PriorityQueueTest {

	public static void main(String[] args) {
		PriorityQueue q = new PriorityQueue(15);

		Random gen = new Random();
		int nTrials = gen.nextInt(25);

		System.out.println("Generating " + nTrials + " random trials");
	for (int t = 0; t < nTrials; t++) {
		System.out.println("Begin trial " + t);

		System.out.println("Inserting random events until queue full");
		while (q.queueFull() != true)
		{
			int pri = gen.nextInt(201);
			Event e = new Event(pri,"RAND"+pri);
			boolean r = q.insertEvent(e);
			if (r == true) {
				System.out.println("Insertion successful");
			} 
			else
			{
				System.out.println("Insertion failed");
			}
		}

		System.out.println("Queue Full");

		
		System.out.println("QUEUE STRUCTURE");
		System.out.println("---------------");
		q.printQueue();
		
		System.out.println("Flushing the queue");
		
		for (int i = 0; i < 15; i++) {
			Event e = q.getEvent();
			System.out.println("EVENT PR: " + e.getPriority() + " INF: " + e.getString());
		}
		System.out.println("Trial over");
	}

	}
}
